
# encoding:utf-8

import requests
import base64
from PIL import Image
import numpy as np


im=Image.open('./8848.png')
# im.show()
im=np.array(im)

im1=im[:, :, 0]
Image.fromarray(im1).show()
# class BaiDuOcr:
#     def __init__(self,):
# # client_id 为官网获取的AK， client_secret 为官网获取的SK
#         self.host = 'https://aip.baidubce.com/oauth/2.0/token?grant_type=client_credentials&client_id=aW3ZqOv2SuG03dC7OemS59Ww&client_secret=xZXRGQDW1krlYaoy5POw4WwEaQveqxA4'

#     def excute(self,imgpath):
#         response = requests.get(self.host)
#         if response:
#             res=response.json()['access_token']
#         request_url = "https://aip.baidubce.com/rest/2.0/ocr/v1/general"
#         # 二进制方式打开图片文件
#         f = open(imgpath, 'rb')
#         img = base64.b64encode(f.read())

#         params = {"image":img}
#         access_token = res
#         request_url = request_url + "?access_token=" + access_token
#         headers = {'content-type': 'application/x-www-form-urlencoded'}
#         response = requests.post(request_url, data=params, headers=headers)
#         if response:
#             # print (response.json()['words_result'])
#             words_result=response.json()['words_result']
#         wordarr=[]
#         for i in range(0, len(words_result)):
#             wordarr.append(words_result[i]['words'])   
#         print(wordarr)
#         return wordarr



import heapq
 
a=[1,2,3,4,5]
re1 = map(a.index, heapq.nlargest(3, a)) #求最大的三个索引    nsmallest与nlargest相反，求最小
re2 = heapq.nlargest(3, a) #求最大的三个元素
print(list(re1)) #因为re1由map()生成的不是list，直接print不出来，添加list()就行了

